#ifndef SOURCEDETAIL_H
#define SOURCEDETAIL_H

#include <QObject>
#include <QList>
#include <QUrl>
#include <QImage>
#include <QMap>

#include "categorydetail.h"


class SourceInfo: public QObject
{
    Q_OBJECT
public:
    explicit SourceInfo(  int sourceId,
                          QString nameSource,
                          QUrl urlLinkSource,
                          QUrl urlSourceImageDomain,
                          const QString fullName ="",
                          QObject *parent = 0)
        : QObject(parent)
        ,m_Id(sourceId)
        ,m_name(nameSource)
        ,m_urlLink(urlLinkSource)
        ,m_urlImageDomain(urlSourceImageDomain)
        ,m_fullNameImage(fullName)

    {

    }
    SourceInfo(const SourceInfo& sInfo)
        :QObject()
        ,m_Id(sInfo.id())
        ,m_name(sInfo.name())
        ,m_urlLink(sInfo.urlLink())
        ,m_urlImageDomain(sInfo.urlImageDomain())
        ,m_fullNameImage(sInfo.getFullNameImage())

    {
        sInfo.getFullNameImage();
    }

    void operator=(const SourceInfo& sInfo){
        m_Id = sInfo.id();
        m_name = sInfo.name();
        m_urlLink = sInfo.urlLink();
        m_urlImageDomain = sInfo.urlImageDomain();
        m_fullNameImage = sInfo.getFullNameImage();       
    }

    inline int id() const {
        return m_Id;
    }

    inline QString name() const {
        return m_name;
    }

    inline QUrl urlLink() const {
        return m_urlLink;
    }

    inline QUrl urlImageDomain() const {
        return m_urlImageDomain;
    }

    inline QString getFullNameImage() const {
        return m_fullNameImage;
    }

    QString getUpdateFullNameImage() ;

    inline void setFullNameImage(const QString& image)
    {
        m_fullNameImage = image;
    }

private:
    int m_Id;
    QString m_name;
    QUrl m_urlLink;
    QUrl m_urlImageDomain;
    QString m_fullNameImage;

};

/*
 *  chua thong tin cuar SourceInfo va data cua source
 */
class SourceDetail: public QObject
{
    Q_OBJECT
public:
    explicit SourceDetail(    int sourceId,
                              QString nameSource,
                              QUrl urlLinkSource,
                              QUrl urlSourceImageDomain,
                              QList < CategoryDetail* > listCategoryPaper,
                              QMap< int, CategoryDetail*> mapIdCategoryDetail,
                              QObject *parent = 0);


    inline int sourceId() const {
        return m_sourceInfo.id();
    }

    inline QString nameSource() const {
        return m_sourceInfo.name();
    }

    inline QList < CategoryDetail* > listCategoryDetail() const {
        return m_listCategoryDetail;
    }

    inline QUrl urlLinkSource() const {
        return m_sourceInfo.urlLink();
    }

    inline QUrl urlSourceImageDomain() const {
        return m_sourceInfo.urlImageDomain();
    }

    inline SourceInfo getSourceInfo()const
    {
        return m_sourceInfo;
    }

    inline int sizeListCategory()
    {
        return m_listCategoryDetail.size();
    }

    CategoryDetail* getCategoryDetailByIndex(const int idx);
    CategoryDetail* getCategoryDetailByKey(const int key);

    int getIndexByCategoryId(const int categoryId);
    int getCategoryIdByIndex(const int index);
    void setCactegoryDetail(CategoryDetail* categoryDetail);

private:

    SourceInfo m_sourceInfo;
    QList < CategoryDetail* > m_listCategoryDetail;
    QMap< int, CategoryDetail*> m_mapIdCategoryDetail;


};

#endif // SOURCECATEGORYINFO_H
